Skip to content

fix: add type json in headers#1614

Open
ApMatheus wants to merge 2 commits into
deco-cx:mainfrom
ApMatheus:fix/reviews
Open

fix: add type json in headers#1614
ApMatheus wants to merge 2 commits into
deco-cx:mainfrom
ApMatheus:fix/reviews

Conversation

@ApMatheus

@ApMatheus ApMatheus commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Adicionei "content-type": "application/json" nas três chamadas (rating, ratings, reviews).


Summary by cubic

Add JSON Content-Type to Verified Reviews POST requests and fix how fullReview formats and merges data. Prevents API failures and returns correctly structured reviews with stats.

  • Bug Fixes
    • Set content-type: application/json for rating, ratings, and reviews via shared jsonHeaders.
    • Fix fullReview to merge ratings with the first reviews payload and include stats; map items with toReview.
    • Use the correct fullReview error message and return empty arrays/undefined consistently.

Written for commit fc385af. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Refactor
    • Improved the internal implementation of the verified reviews client while keeping the same public response shape and pagination behavior.
  • Bug Fixes
    • Enhanced how full reviews and stored reviews handle edge cases (such as empty or missing responses), ensuring consistent aggregate rating and review lists even when requests fail.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 41288417-e4b0-43a5-8c00-13e875a4e71a

📥 Commits

Reviewing files that changed from the base of the PR and between a65d91a and fc385af.

📒 Files selected for processing (1)
  • verified-reviews/utils/client.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • verified-reviews/utils/client.ts

📝 Walkthrough

Walkthrough

verified-reviews/utils/client.ts is refactored without changing public contracts: request payloads for rating, ratings, and reviews are reformatted to use shorthand fields; fullReview replaces flat() with an explicit tuple cast on Promise.all results; storeReview switches its fallback to ??; and the ClientVerifiedReviews type alias and return statement are repositioned.

Changes

createClient helper refactoring

Layer / File(s) Summary
rating, ratings, and reviews payload reformatting
verified-reviews/utils/client.ts
rating and ratings payloads use shorthand field names and introduce local baseUrl/jsonHeaders constants. reviews parameter typing and payload field layout are adjusted while preserving the outgoing request content.
fullReview tuple cast and storeReview nullish coalescing
verified-reviews/utils/client.ts
fullReview removes the flat() call and destructures Promise.all results with an explicit tuple cast. storeReview replaces (response ? response : []) with response ?? [].
Type relocation and return statement repositioning
verified-reviews/utils/client.ts
ClientVerifiedReviews type alias and the createClient return object are relocated to the end of the function; signatures are unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A hop through the client, a tidy affair,
Shorthand fields shimmer, flat() gone from there,
?? [] now guards where a truthy once stood,
Tuple cast gleams in the Promise.all wood,
The return slips to end, the type finds its place —
Same contract, fresh fur, a neatened-up space! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks key template sections including 'What is this Contribution About', proper 'Issue Link', 'Loom Video', and 'Demonstration Link'. While an auto-generated summary by cubic is included, the required template structure is not followed. Add the required template sections: provide a brief description in the 'What is this Contribution About' section, include the Issue Link with the relevant GitHub issue number, and add Loom Video and Demonstration Link sections as specified in the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions adding JSON content-type in headers, which aligns with the main objective of adding Content-Type headers to API requests, though it is somewhat narrow and doesn't fully capture all changes in the implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.158.1 update
  • 🎉 for Minor 0.159.0 update
  • 🚀 for Major 1.0.0 update

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@verified-reviews/utils/client.ts`:
- Around line 151-155: The Promise.all type cast on lines 151-155 declares the
second result as Reviews | null, but since reviews() returns Promise<Reviews[]>
and flat() was removed, responseReview is actually an array at runtime. This
causes lines 162/164 to try accessing object properties like stats and reviews
from an array, resulting in incomplete or undefined data. Update the Promise.all
type cast to declare the second result as Reviews[] instead of Reviews | null so
the subsequent code that accesses stats and reviews properties on lines 162/164
operates on the correct shape.
- Line 110: The `reviews` function is declared as `async` but does not contain
any `await` expressions, which causes a CI/static-analysis failure. Remove the
`async` keyword from the `reviews` function declaration since it directly
returns the result of `fetchAPI(...)` without awaiting any asynchronous
operations. This will align the function signature with its actual behavior and
clear the failing check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a73d5be6-f000-401a-b122-243357388166

📥 Commits

Reviewing files that changed from the base of the PR and between 192c63c and a65d91a.

📒 Files selected for processing (1)
  • verified-reviews/utils/client.ts


/** @description https://documenter.getpostman.com/view/2336519/SVzw6MK5#daf51360-c79e-451a-b627-33bdd0ef66b8 */
const reviews = (
const reviews = async (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove unnecessary async on reviews to clear the failing check

Line 110 declares reviews as async but returns fetchAPI(...) directly with no await, which matches the reported CI/static-analysis failure.

Suggested fix
-  const reviews = async (
+  const reviews = (
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const reviews = async (
const reviews = (
🧰 Tools
🪛 GitHub Actions: ci / 0_Bundle & Check Apps (ubuntu-latest).txt

[error] 110-110: deno lint failed (require-await): Async arrow function has no 'await' expression or 'await using' declaration.

🪛 GitHub Actions: ci / Bundle & Check Apps (ubuntu-latest)

[error] 110-110: deno lint failed (require-await): Async arrow function has no 'await' expression or 'await using' declaration.

🪛 GitHub Check: Bundle & Check Apps (ubuntu-latest)

[failure] 110-110:
�[0m�[1mAsync arrow function has no 'await' expression or 'await using' declaration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@verified-reviews/utils/client.ts` at line 110, The `reviews` function is
declared as `async` but does not contain any `await` expressions, which causes a
CI/static-analysis failure. Remove the `async` keyword from the `reviews`
function declaration since it directly returns the result of `fetchAPI(...)`
without awaiting any asynchronous operations. This will align the function
signature with its actual behavior and clear the failing check.

Source: Linters/SAST tools

Comment thread verified-reviews/utils/client.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread verified-reviews/utils/client.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant